import axios from '../axios';

export const userApi = {
    userPage: (data)=>{
        return axios.get('/user/page',{params:data})
        .then(response => response.data)
        .catch(error => {
            throw new Error(error);
        });
    },
    //搜索用户
    searchUser:(username)=>{
         return axios.post('/user/getuser/username?userName='+username,{})
        .then(response => response)
        .catch(error => {
            throw new Error(error);
        });
    },
    searchUserByUid:(uid)=>{
         return axios.post('/user/getuser/userId?userId='+uid,{})
        .then(response => response)
        .catch(error => {
            throw new Error(error);
        });
    },
    //添加朋友
    addUserFriend:(data)=>{
        return axios.post('/friend/group/save',data)
        .then(response => response)
        .catch(error => {
            throw new Error(error);
        });
    },
    //获取朋友列表
    getFriendList:(data)=>{
          return axios.get('/friend/group/page',{params:data})
        .then(response => response)
        .catch(error => {
            throw new Error(error);
        });
    }
}